<template>
  <div class="main">
    <div class="box">
      <div class="front">
        <img src="./1.png" style="width: 100%; height: 100%" alt="" />
      </div>
      <div class="center"></div>
      <div class="reverse">反面</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
};
</script>

<style lang="less" scoped>
.main {
  width: 300px;
  height: 200px;
  margin: 50px auto;
  perspective: 800px;
  .box {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    position: relative;
    transition: all 1s ease;
    .front {
      width: 100%;
      height: 100%;
      background: #ff00ff;
      transform: translateZ(100px);
    }
    .reverse {
      width: 120px;
      height: 120px;
      background: #ffff00;
      position: absolute;
      left: 50%;
      top: 50%;
      margin: -60px 0 0 -60px;
      transform: rotateY(180deg);
    }
    .center {
      background: #000;
      width: 100%;
      height: 100%;
      opacity: 0.3;
      transform: translateZ(98px);
      position: absolute;
      left: 0;
      top: 0;
    }
  }
  &:hover .box {
    transform: rotateY(-180deg);
  }
}
</style>  